using dtPolyRef = System.UInt32;

namespace Recast
{
	public unsafe partial class RecastGlobal
	{
		public unsafe partial class dtCollectPolysQuery : dtPolyQuery
		{
			public dtPolyRef* m_polys;
			public int m_maxPolys;
			public int m_numCollected;
			public bool m_overflow;
			public dtCollectPolysQuery(dtPolyRef* polys, int maxPolys)/*: m_polys(polys), m_maxPolys(maxPolys), m_numCollected(0), m_overflow(false)*/
			{
				m_polys = polys;
				m_maxPolys = maxPolys;
			}
			~dtCollectPolysQuery()
			{
			}
			public int numCollected()
			{
				return m_numCollected;
			}
			public bool overflowed()
			{
				return m_overflow;
			}
			public override void process(dtMeshTile* tile, dtPoly* polys, dtPolyRef* Refs, int count)
			{
				dtIgnoreUnused(tile);
				dtIgnoreUnused(polys);
				int numLeft = m_maxPolys - m_numCollected;
				int toCopy = count;
				if (toCopy > numLeft)
				{
					m_overflow = true;
					toCopy = numLeft;
				}
				memcpy(m_polys + m_numCollected, Refs, (int)toCopy * sizeof(dtPolyRef));
				m_numCollected += toCopy;
			}
		}
	}
}
